package com.shujia.wyh.day08;

/*
    StringBuffer类：线程安全的可变字符序列

    构造方法：
        public StringBuffer()
        public StringBuffer(int capacity)
        public StringBuffer(String str)

 */
public class StringBufferDemo1 {
    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer();
//        System.out.println(sb); //重写了toString()方法
        //获取默认创建的容量大小
        System.out.println(sb.capacity());

        //public StringBuffer(int capacity)
        //指定容量大小创建StringBuffer
        StringBuffer sb2 = new StringBuffer(10000);
        System.out.println(sb2.capacity());

        //public StringBuffer(String str)
        StringBuffer sb3 = new StringBuffer("hello");
        System.out.println(sb3);
        System.out.println(sb3.capacity()); //获取容量的大小
        System.out.println(sb3.length()); //获取真实存储的字符个数
    }
}
